package com.sdry.product.sorting.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sdry.basic.entity.Material;
import com.sdry.common.BaseController;
import com.sdry.common.TableDataInfo;
import com.sdry.product.sorting.entity.SortFrame;
import com.sdry.product.sorting.service.SortingStockService;
import com.sdry.system.entity.SysUser;
import com.sdry.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @program: info_sdry
 * @description: 分拣区库存 也就是半成品上架，扫描上架就是入库存
 * @author: cb
 * @create: 2020-02-27 18:09
 **/
@Controller
@RequestMapping(value = "sortingStock")
public class SortingStockController extends BaseController {

    @Autowired
    private SortingStockService sortingStockService;

    @Autowired
    private UserService userService;

    /**
     * 展示上架/库存
     * @return
     */
    @RequestMapping(value = "showSortingStock")
    public String showSortingStock() {
        return "/product/sorting/stock";
    }

    /**
     * 分页查询上架/库存
     * @param sortFrame
     * @return
     */
    @RequestMapping(value = "querySortingStockPage")
    @ResponseBody
    public TableDataInfo querySortingStockPage(SortFrame sortFrame) {
        List<SortFrame> sortFrameList = sortingStockService.querySortingStockPage(sortFrame);
        Long total = sortingStockService.querySortingStockTotal(sortFrame);
        return getDataTable(sortFrameList,total);
    }
    /**
     * 分页查询出库
     * @param sortFrame
     * @return
     */
    @RequestMapping(value = "querySortingStockOutPage")
    @ResponseBody
    public TableDataInfo querySortingStockOutPage(SortFrame sortFrame) {
        List<SortFrame> sortFrameList = sortingStockService.querySortingStockOutPage(sortFrame);
        Long total = sortingStockService.querySortingStockOutTotal(sortFrame);
        return getDataTable(sortFrameList,total);
    }

    /**
     * 库存详细
     * @param maId 容器ID
     * @return
     */
    @RequestMapping(value = "querySortingStockDetailPage")
    @ResponseBody
    public TableDataInfo querySortingStockDetailPage(SortFrame sortFrame) {
        List<SortFrame> materialList =  sortingStockService.querySortingStockDetailPage(sortFrame);
        Long total = sortingStockService.querySortingStockDetailTotal(sortFrame);
        return getDataTable(materialList,total);
    }
}
